<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../include/tag.jsp"%>
<!DOCTYPE html>
<html lang="zh">
<head>
<title>${circle.id == null ? '添加' : '编辑'}用户类型</title>
<%@include file="../include/commonFile.jsp"%>
<link rel="stylesheet" href="${ctx}/css/common/list.css">
<link rel="stylesheet" href="${ctx}/css/common/form.css">
</head><body>
<!--头部-->
<%@include file="../include/header.jsp"%>
<div class="index-outside">
	<%@include file="../include/sidebar.jsp"%>
	<!--内容-->
	<section>
		<div class="section-main">
			<%--<div class="c-time-list-header">
				<div class="r">
					<a href="javascript:history.back();" class="layui-btn layui-btn-radius layui-btn-danger"> <i
						class="iconfont icon-back btn-icon"></i>返回
					</a>
				</div>
				<div class="ovh">
					<span class="title f18">我创建的圈子&nbsp;&gt;&nbsp;${circle.name}&nbsp;&gt;&nbsp;用户类型管理&nbsp;&gt;&nbsp; ${type == null ? '创建' : '编辑'}用户类型</span>
				</div>
			</div>--%>
			<!-- 正文请写在这里 -->
			<div class="add-form-content">
			<form id="myForm" class="layui-form mt20" method="post" action="${ctx}/circle/tag/save.do">
				<input type="hidden" name="id" value="${tag.id}" />
				<input type="hidden" name="circle" value="${circleId}" />
				<div class="layui-form-item">
					<label class="layui-form-label">名称<span class="f-verify-red">*</span></label>
					<div class="layui-input-block">
						<input type="text" name="tagName" lay-verify="tagName"
							placeholder="请输入用户类型名称" class="layui-input" value="${tag.tagName}">
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">排序号</label>
						<div class="layui-input-inline">
							<input type="tel" name="sort" lay-verify="sort" class="layui-input" value="${tag.sort}">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn layui-btn-danger" lay-submit lay-filter="*">立即提交</button>
						<a href="${ctx}/circle/tag/list.do?circle=${circleId}" class="layui-btn layui-btn-primary">取消</a>
					</div>
				</div>
			</form>
			</div>
		</div><!--底部-->
		<%@include file="../include/footer.jsp"%>
	</section>
</div>

<script>
	$(function() {
		layui.use([ 'form' ], function() {
			var form = layui.form;
			//自定义验证规则
			form.verify({
				tagName : function(value) {
					if (value == "") {
						return '请填写用户类型名称';
					}
				},
				sort : function(value) {
					if (!util.checkNumber(value)) {
						return "请输入正确的数字";
					}
				}
			});

			//监听提交
            form.on('submit', function (data) {
                txz.submitObject(data.elem, function (callBack) {
                    var action = $("#myForm").attr("action");
                    $.post(action, $('#myForm').serialize(), function (res) {
                        typeof callBack === 'function' && callBack();
                        if (res.success) {
                            util.layerMsgSuccess("提交成功", function () {
                                location.href = "${ctx}/circle/tag/list.do?circle=${circleId}";
                            });
                        } else {
                            util.layerMsgError("提交失败")
                        }
                    });
                }, '${tag.id}')
                return false;
            });
		});
	})
</script>

<script type="text/javascript">
	txz.initHeader({
		nav:[{
			name: '我创建的圈子'
		},{
			name: '${circle.name}'
		},{
			name: '用户类型管理'
		},{
            name: '${empty tag.id ? '添加用户类型' : '编辑用户类型'}',
			curr: true
		}],
		btns:[{
			name: '返回',
			icon: 'back',
			href: 'javascript:history.back();'
		}]
	});
</script>
</body>
</html>